package com.by.sql;

/**
 * @version 1.0
 * @Author 彭彦彬
 * @Date 2025/4/9 11:01
 * @注释
 */
import java.util.List;

public class Page<T> {
    private int pageNum; // 当前页码
    private int pageSize; // 每页大小
    private long total; // 总记录数
    private List<T> records; // 当前页数据

    public Page(int pageNum, int pageSize) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
    }

    public String toLimitSql() {
        int offset = (pageNum - 1) * pageSize;
        return " LIMIT " + offset + ", " + pageSize;
    }

    public int getPageNum() {
        return pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public List<T> getRecords() {
        return records;
    }

    public void setRecords(List<T> records) {
        this.records = records;
    }
}
